package com.community.common.controller;


import com.community.common.pojo.PageRequest;
import com.community.common.pojo.domain.Building;
import com.community.common.pojo.dto.BuildingPageQueryDto;
import com.community.common.pojo.response.LayuiPage;
import com.community.common.pojo.response.MyResponse;
import com.community.common.service.BuildingService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * <p>
 * 楼栋表 前端控制器
 * </p>
 *
 * @author superman
 * @since 2020-08-02
 */
@Controller
@RequestMapping("/building")
public class BuildingController {

    @Resource
    private BuildingService buildingService;

    @ResponseBody
    @PostMapping("/add")
    public MyResponse add(Building building) {
        return buildingService.add(building);
    }

    @ResponseBody
    @PostMapping("/pageQuery")
    public LayuiPage queryByPage(@RequestBody PageRequest<BuildingPageQueryDto> pageQueryDto) {
        return LayuiPage.parsePage(buildingService.pageQuery(pageQueryDto));
    }

}
